package dy.spec.edu.week12_class01;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class WordAdapter extends ArrayAdapter<Word> {
    private int itemLayoutId;
    public WordAdapter(Context context, int resource, List<Word> objects) {
        super(context, resource, objects);
        itemLayoutId=resource;
    }
    public View getView(int position, View convertView, ViewGroup parent) {
        Word xx = getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(itemLayoutId, parent, false);
        ImageView MI = view.findViewById(R.id.imageId);
        TextView Mt = view.findViewById(R.id.title);
        TextView Mc = view.findViewById(R.id.content);
        MI.setImageResource(xx.getImageId());
        Mt.setText(xx.getTitle());
        Mc.setText(xx.getContent());
        return view;
    }
}
